//
//  WXPMineUserInfoView.m
//  MexicoLoan
//
//  Created by wxp on 2025/2/26.
//

#import "WXPMineUserInfoView.h"

@implementation WXPMineUserInfoView

#pragma mark - lazy
- (UIImageView *)imagePhoto {
    if (_imagePhoto == nil) {
        _imagePhoto = [UIImageView new];
        _imagePhoto.widthHeight = XY(60, 60);
    }
    return _imagePhoto;
}

- (UILabel *)labelName {
    if (_labelName == nil) {
        _labelName = [UILabel new];
        _labelName.textColor = COLOR_BLACK;
        _labelName.font = [UIFont boldSystemFontOfSize:16];
    }
    return _labelName;
}

- (UIView *)viewBack {
    if (_viewBack == nil) {
        _viewBack = [UIView new];
        _viewBack.backgroundColor = COLOR_WHITE;
        [GlobalMethod setRoundView:_viewBack color:[UIColor clearColor] numRound:16 width:0];
    }
    return _viewBack;
}

- (UIView *)viewLine {
    if (_viewLine == nil) {
        _viewLine = [UIView new];
        _viewLine.backgroundColor = COLOR_LINE;
        _viewLine.widthHeight = XY(1, 36);
    }
    return _viewLine;
}

- (UILabel *)labelCuotaTitle {
    if (_labelCuotaTitle == nil) {
        _labelCuotaTitle = [UILabel new];
        _labelCuotaTitle.textColor = COLOR_BLACK;
        _labelCuotaTitle.font = [UIFont systemFontOfSize:12];
    }
    return _labelCuotaTitle;
}

- (UILabel *)labelCuota {
    if (_labelCuota == nil) {
        _labelCuota = [UILabel new];
        _labelCuota.textColor = COLOR_BLACK;
        _labelCuota.font = [UIFont boldSystemFontOfSize:20];
    }
    return _labelCuota;
}

- (UILabel *)labelMontoTitle {
    if (_labelMontoTitle == nil) {
        _labelMontoTitle = [UILabel new];
        _labelMontoTitle.textColor = COLOR_BLACK;
        _labelMontoTitle.font = [UIFont systemFontOfSize:12];
    }
    return _labelMontoTitle;
}

- (UILabel *)labelMonto {
    if (_labelMonto == nil) {
        _labelMonto = [UILabel new];
        _labelMonto.textColor = COLOR_BLACK;
        _labelMonto.font = [UIFont boldSystemFontOfSize:20];
    }
    return _labelMonto;
}


#pragma mark - 初始化
- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.widthHeight = XY(SCREEN_WIDTH, 0);
        self.backgroundColor = [UIColor clearColor];
        [self addSubView];
    }
    return self;
}

- (void)addSubView{
    [self addSubview:self.imagePhoto];
    [self addSubview:self.labelName];
    [self addSubview:self.viewBack];
    
    [self.viewBack addSubview:self.labelCuotaTitle];
    [self.viewBack addSubview:self.labelCuota];
    [self.viewBack addSubview:self.viewLine];
    [self.viewBack addSubview:self.labelMontoTitle];
    [self.viewBack addSubview:self.labelMonto];
    
    [self resetView];
}

#pragma mark - 刷新View
- (void)resetView{
    self.imagePhoto.leftTop = XY(LEFT_MARDIN, 6);
    self.imagePhoto.backgroundColor = [UIColor clearColor];
    self.imagePhoto.image = [UIImage imageNamed:@"icon-mine-photo"];
    
    //[self.labelName fitTitle:@"Hola！******" variable:0];
    [self.labelName fitTitle:[NSString stringWithFormat:@"Hola！%@",[GlobalData sharedInstance].Global_ModelUser.phone] variable:0];
    self.labelName.leftCenterY = XY(self.imagePhoto.right+LEFT_MARDIN, self.imagePhoto.centerY);
    
    self.viewBack.widthHeight = XY(SCREEN_WIDTH-LEFT_MARDIN*2, 95);
    self.viewBack.centerXTop = XY(SCREEN_WIDTH/2, self.imagePhoto.bottom+26);
    
    self.viewLine.centerXCenterY = XY(self.viewBack.width/2, self.viewBack.height/2);
    
    [self.labelCuotaTitle fitTitle:@"Cuota disponible" variable:0];
    self.labelCuotaTitle.centerXTop = XY(self.viewBack.width/4, 26);
    
    [self.labelCuota fitTitle:[NSString stringWithFormat:@"$ %@", [GlobalMethod showMoney:strDot2F([GlobalData sharedInstance].Global_ModelUser.unused)]] variable:0];
    self.labelCuota.centerXTop = XY(self.labelCuotaTitle.centerX, self.labelCuotaTitle.bottom+10);
    
    [self.labelMontoTitle fitTitle:@"Monto por reembolsar" variable:0];
    self.labelMontoTitle.centerXCenterY = XY(self.viewBack.width/4*3, self.labelCuotaTitle.centerY);
    [self.labelMonto fitTitle:[NSString stringWithFormat:@"$ %@", [GlobalMethod showMoney:strDot2F([GlobalData sharedInstance].Global_ModelUser.repaymentRemainAmount)]] variable:0];
    self.labelMonto.centerXCenterY = XY(self.labelMontoTitle.centerX, self.labelCuota.centerY);
    
    self.height = self.viewBack.bottom+LEFT_MARDIN;
}

@end
